﻿using AutoMapper;
using HuaweiCloud.Dotnet.Samples.Common;
using HuaweiCloud.Dotnet.Samples.ESports.Common;
using HuaweiCloud.Dotnet.Samples.ESports.Main.Dtos;
using HuaweiCloud.Dotnet.Samples.ESports.Main.Entities;

namespace HuaweiCloud.Dotnet.Samples.ESports.Main.Service
{
    public class DeviceService
        : CrudApplicationServiceBase<Device, CreateDeviceDto, UpdateDeviceDto, DeviceDto>
         , IDeviceService
    {
        public DeviceService(IRepository<Device> repository, IMapper mapper) : base(repository, mapper)
        {
        }

        public override Task AddAsync(CreateDeviceDto t, CancellationToken token = default)
        {
            if (t.Type == null)
                //|| !DeviceTypeConst.Types.Contains(t.Type))
                throw new InvalidDataException("Invalid Type");
            return base.AddAsync(t, token);
        }

    }
}
